<?php
class PageType extends Action {
	/*
	 * (non-PHPdoc) @see Action::execute()
	 */
	public function execute($params) {
		check_login ( ADMIN_LOGIN_PAGE );
		$data = array ();
		
		$typeModel = new WebPageTypeModel ();
		
		$typeModel->sort ( array ('page_type', 'd' ) );
		
		$types = $typeModel->where ( $where )->count ( true )->retrieve ();
		
		$data ['curl'] = $this->url;
		
		if ($types) {
			$data ['items'] = $types;
		}
		
		$data['type'] = sess_del('page_type_info',array());
		$data ['error'] = sess_del ( 'page_type_error', array () );
		$data ['error_cls'] = ModelValidator::getErrorCls ( $data ['error'] );
		
		bind ( 'page_type_options', array ($this, 'page_type_options' ), 10, 2 );
		
		return new SmartyView ( $data, 'theme/PageType' );
	}
	
	public function page_type_options($ops, $item) {
		$ops .= '<a title="编辑" href="./?Ctlr=EditType&tid=' . $item ['page_type_id'] . '"><i class="icon-edit"></i></a>';
		$ops .= '<a title="删除" onclick="return confirm(\'确定要删除该页面类型?\');" href="./?Ctlr=DelType&tid=' . $item ['page_type'] . '"><i class="icon-trash"></i></a>';
		return $ops;
	}
}